home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
kbdtest.asm
< prev
next >
Wrap
Assembly Source File
|
1985-06-03
|
13KB
|
506 lines
TITLE KBDTEST.ASM Keyboard check out program for the Chameleon keyboard
PAGE ,132
;----------------------------------------------------------------------
;
; KBDTEST is designed to check out the Chameleon keyboard.
; No exit to DOS is provided.
;
; by: Michael Searles Jan. 1984
;
;----------------------------------------------------------------------
SUBTTL ROM bios interupt equates
PAGE
keybdIO equ 16H ;interupt for key board IO
key_in equ 0
key_status equ 1
shift_status equ 2
videoIO equ 10H
set_cur_type equ 1
pos_cursor equ 2
read_cur_pos equ 3
select_page equ 5
scroll_up equ 6
scroll_down equ 7
chr_att_in equ 8
chr_att_out equ 9
chrs_out equ 10
chr_out equ 14
read_status equ 15
cr equ 0DH
lf equ 0AH
eos equ 04H
stack SEGMENT STACK
org 100H
top_of_stack LABEL WORD
stack ENDS
SUBTTL data segment
PAGE
data SEGMENT PUBLIC 'data'
att_length DW ? ;contains the char count for set_attribute
current_mode DB ? ;current crt mode
current_page DB ? ;current video display page
cursor_start DB ? ;cursor start data
end_of_scroll DW ?
key_loc DW ? ;temporarily holds screen position
key_loc2 DW ? ;for bottom of blocks
line_buffer DB 80 DUP (?) ;input buffer for Getstring
scroll_count DB ?
shift_stat_reg DB ? ;holds shift status byte
start_of_scroll DW ?
STRING_PTR DW ? ;addr of the start of convert buffer
DB 10 DUP(?) ;buffer for convert to decimal string
string_base DB ' ',eos ;end of convert buffer
video_attribute DB brite ;attribute to use on screen
normal equ 00000111B ;normal video attribute
brite equ 00001111B ;high intensity
inversnormal equ 01110000B ;invers normal letters
inversbrite equ 01111000B ;invers fat letters
blinking equ 10000111B ;blinking letters
;==================================DATA TABLES=================================
;In keytable ---> LOW byte = character code
; HIGH byte = scan code
; F1 F2 ESC 1 ! 2 @ 3 # 4 $ 5 % 6
keytable DW 3B00H,3C00H,011BH,0231H,0221H,0332H,0340H,0433H,0423H,0534H,0524H,0635H,0625H,0736H
; ^ 7 & 8 * 9 ( 0 ) - _ = +
DW 075EH,0837H,0826H,0938H,092AH,0A39H,0A28H,0B30H,0B29H,0C5FH,0C2DH,0D3DH,0D2BH
; BS NL SL F3 F4 --> <-- Q q W w E e R r
DW 0E08H,4500H,4600H,3D00H,3E00H,0F09H,0F00H,1051H,1071H,1157H,1177H,1245H,1265H,1352H,1372H
; T t Y y U u I i O o P p
DW 1454H,1474H,1559H,1579H,1655H,1675H,1749H,1769H,184FH,186FH,1950H,1970H
; [ { ] } RET HOM 7 UP 8 PGU 9 - F5 F6 CTL A a
DW 1A5BH,1A7BH,1B7DH,1B5DH,1C0DH,4700H,4737H,4800H,4838H,4900H,4939H,4A2DH,3F00H,4000H,1D00H,1E41H,1E61H
; S s D d F f G g H h J j K k
DW 1F53H,1F73H,2044H,2064H,2146H,2166H,2247H,2267H,2348H,2368H,244AH,246AH,254BH,256BH
; L l : ; " ' ~ ` <-- 4 5 --> 6 F7 F8 sft
DW 264CH,266CH,273AH,273BH,2822H,2827H,297EH,2960H,4B00H,4B34H,4C35H,4D00H,4D36H,4100H,4200H,3600H
; | \ Z z X x C c V v B b N n
DW 2B7CH,2B5CH,2C5AH,2C7AH,2D58H,2D78H,2E43H,2E63H,2F56H,2F76H,3042H,3062H,314EH,316EH
; M m < , > . ? / sft * END 1 DN 2 PgDn 3 + F9
DW 324DH,326DH,333CH,332CH,343EH,342EH,353FH,352FH,3600H,372AH,4F00H,4F31H,5000H,5032H,5100H,5133H,4E2BH,4300H
; F10 ALT SPA CL INS 0 . DEL
DW 4400H,38FFH,3920H,3A00H,5200H,8030H,532EH,5300H
keytable_length equ $-keytable
;key_location --> high byte = screen row
; low byte = screen column
key_location DW 0600H,0602H,0604H,0608H,0608H,060AH,060AH,060CH,060CH ;
DW 060EH,060EH,0610H,0610H,0612H,0612H,0614H,0614H,0616H ;TOP ROW
DW 0616H,0618H,0618H,061AH,061AH,061CH,061CH,061EH,061EH ;
DW 0620H,0622H,0624H ;
DW 0900H,0902H,0904H,0904H,0907H,0907H,0909H,0909H,090BH ;
DW 090BH,090DH,090DH,090FH,090FH,0911H,0911H,0913H,0913H ; Q ROW
DW 0915H,0915H,0917H,0917H,0919H,0919H,091BH,091BH,091DH ;
DW 091DH,091FH,0922H,0922H,0924H,0924H,0926H,0926H,0927H ;
DW 0C00H,0C02H,0C0EH,0C08H,0C08H,0C0AH,0C0AH,0C0CH,0C0CH ;
DW 0C0EH,0C0EH,0C10H,0C10H,0C12H,0C12H,0C14H,0C14H,0C16H ; A ROW
DW 0C16H,0C18H,0C18H,0C1AH,0C1AH,0C1CH,0C1CH,0C1EH,0C1EH ;
DW 0C22H,0C22H,0C24H,0C26H,0C26H ;
DW 0F00H,0F02H,0F11H,0F07H,0F07H,0F09H,0F09H,0F0BH,0F0BH ;
DW 0F0DH,0F0DH,0F0FH,0F0FH,0F11H,0F11H,0F13H,0F13H,0F15H ; Z ROW
DW 0F15H,0F17H,0F17H,0F19H,0F19H,0F1BH,0F1BH,0F1DH,0F1FH ;
DW 0F22H,0F22H,0F24H,0F24H,0F26H,0F26H,0F27H ;
DW 1200H,1202H,1209H,120DH,121BH,121FH,121FH,1225H,1225H ;BOTTOM ROW
;This table is to fill the bottom section of the function keys & shift keys
; 0 = no extra fill
key_location2 DW 0700H,0702H,28 DUP(0),0A00H,0A02H,0A04H,0A04H,32 DUP(0)
DW 0D00H,0D02H,30 DUP(0),1000H,1002H,1011H,22 DUP(0),101DH
DW 8 DUP(0),1300H,1302H,7 DUP(0)
;fill_length --> number of blocks to fill
fill_length DW 1,1,3,24 DUP (1),2,2,2,1,1,2,2,24 DUP(1),2,9 DUP(1),3
DW 65 DUP(1),3,11,2,3,3,3,3
PAGE
;=============================================================================
;
; Stat_masks ----> 7 6 5 4 3 2 1 0
; | | | | | | | |
; | | | | | | | ---Right shift
; | | | | | | --------Left shift
; | | | | | -------------Control
; | | | | ------------------Alternate
; | | | -----------------------Scroll lock
; | | ----------------------------Num lock
; | ---------------------------------Caps lock
; --------------------------------------Insert mode
;
; 0 = off
; 1 = on or depressed
;
;=============================================================================
stat_masks DW 8080H,4040H,2020H,1010H,0808H,0404H,0202H,0101H
;Status key screen locations
; INS CL NL SL ALT CTL Sft L Sft R
stat_key_loc DW 121FH,121BH,0623H,0626H,1206H,0C04H,0F05H,0F1DH
stat_key_loc2 DW 6 DUP(0),1005H,101DH
stat_key_len DW 3,2,2,2,3,3,1,1
PAGE
;---------------------------------- Messages ------------------------------
; | width = 40 |
overlaymsg DB ' KEYBOARD TEST ',cr,lf,lf,lf,lf,lf
DB 'F F ESC 1 2 3 4 5 6 7 8 9 0 - = BS NL SL ',cr
DB '1 2',cr,lf,lf
DB 'F F <- Q W E R T Y U I O P [ ] <- 7 8 9-',cr
DB '3 4 ->', cr,lf,lf
DB "F F CTL A S D F G H J K L ; ' ` 4 5 6 ",cr
DB '5 6',cr,lf,lf
DB 'F F S \ Z X C V B N M , . ? S * 1 2 3+',cr
DB '7 8 L R ',cr,lf,lf
DB 'F F ALT space CL INS DEL',cr
DB '9 0',cr,lf,lf,eos
key_error_msg DB ' KEY ERROR or undefined key ',eos
blank_msg DB ' ',eos
data ENDS
SUBTTL code section
PAGE
code SEGMENT PUBLIC 'code'
ASSUME cs:code, ds:data, ss:stack
cli
mov ax, SEG stack
mov ss, ax
mov sp, OFFSET top_of_stack
sti
xor ax, ax
pushf
push ds
push ax
mov ax, SEG data
mov ds, ax
mov es, ax
mov video_attribute, blinking
mov current_page, 0
mov current_mode, 0
mov scroll_count, 0
mov start_of_scroll, 0
mov end_of_scroll, 184FH
call set_new_mode
mov cursor_start, 20 ;remove cursor
call cursor
call blank_window
mov dx, 0100H
call mov_cursor
mov att_length, 80
mov video_attribute, brite
call set_attribute ;set for brite title
mov dx, OFFSET overlaymsg
call printstring
mov dx, 1600H
call mov_cursor
mov att_length, 40
call set_attribute ;set for brite ERROR msg
keyboard_check_restart:
call keyboard_check
jmp keyboard_check_restart
iret ;I don't know why!!!
PAGE
keyboard_check:
mov ah, shift_status
int keybdIO ;get current status settings
mov shift_stat_reg,al ;store it
keycheck:
cld ;forward march!
mov ah, shift_status
int keybdIO ;check status keys
cmp shift_stat_reg, al
je no_shift
call shift_stat_check
jmp keyboard_check
no_shift:
call constatus
jz keycheck
mov dx, 1604H
call mov_cursor
mov dx, OFFSET blank_msg
call printstring ;erase error message
call conin ;returns scancode in AH
mov cx, keytable_length ;& character code in AL
mov di, OFFSET keytable
key_loop:
scasw ;compare AX with [DI]
jz found_key
loop key_loop
mov dx, 1604H
call mov_cursor
mov dx, OFFSET key_error_msg
call printstring
jmp keyerror
found_key:
mov bx, keytable_length
sub bx, cx ;how many scasw did we do?
shl bx, 1 ;BX = BX * 2 (for word op's)
mov di, bx
push di
mov dx, OFFSET key_location
add di, dx
mov bx, [di]
mov key_loc, bx ;get location on screen
pop di
push di
mov dx, OFFSET key_location2
add di, dx
mov bx, [di]
mov key_loc2, bx
pop di
mov dx, OFFSET fill_length
add di, dx
mov bx, [di]
mov att_length, bx ;get width to light
mov dx, key_loc
call mov_cursor
mov video_attribute, inversnormal
call set_attribute
mov dx, key_loc2
cmp dx, 0 ;should we fill?
je recheck
call mov_cursor
call set_attribute
recheck:
jmp keycheck
keyerror:
mov dx, 1700H
call mov_cursor
ret
PAGE
;Enters with current status byte in AL
shift_stat_check:
mov ah, shift_stat_reg
mov bx, ax ;save old & new stat registers
mov di, 0 ;reset pointer
mov si, OFFSET stat_masks
mov cx, 8 ;look at 8 bits
stat_loop:
mov ax, bx ;restore old & new stat register
;AL = latest status register
;AH = previous status register
mov dx, [si] ;get mask
and ax, dx ;mask
cmp ah, al ;has this bit changed?
jne found_stat
inc di
inc di
inc si
inc si
loop stat_loop
jmp stat_ret
found_stat:
mov dx, OFFSET stat_key_len
push di
add di, dx
mov bx, [di]
mov att_length, bx
pop di
mov dx, OFFSET stat_key_loc
push di
add di, dx
mov dx, [di]
call mov_cursor
call set_attribute
pop di
mov dx, OFFSET stat_key_loc2
add di, dx
mov dx, [di]
cmp dx, 0 ;should we fill again?
jz stat_ret
call mov_cursor
call set_attribute
stat_ret:
ret
PAGE
;--------------- console IO subroutines -----------------
conout:
push ax
push bx
push bp
mov ah, chr_out
mov bh, current_page
mov bl, 0
int videoIO
pop bp
pop bx
pop ax
ret
conin:
xor ah, ah
int keybdIO
ret
constatus:
push ax
mov ah, key_status
int keybdIO
pop ax
ret
PAGE
set_new_mode:
mov al, current_mode
xor ah, ah
int videoIO
ret
set_attribute:
push ax
push bx
push cx
push dx ;save current cursor position
mov cx, att_length
att_loop:
push cx
mov bh, current_page
mov ah, chr_att_in ;get character at cursor
int videoIO
mov bh, current_page
mov ah, chr_att_out ;write old char & new attribute
mov bl, video_attribute
mov cx, 1
int videoIO
inc dx
call mov_cursor
pop cx
loop att_loop
pop dx
call mov_cursor ;move cursor to original position
pop cx
pop bx
pop ax
ret
mov_cursor:
push ax
push bx
mov ah, pos_cursor
mov bl, current_page
xor bh, bh
int videoIO
pop bx
pop ax
ret
blank_screen: ;cx = row col start of blank
mov ah, scroll_up
mov al, 0
mov bh, video_attribute
mov dx, 1950H
int videoIO
ret
PAGE
blank_window:
push ax
mov ah, scroll_up
mov al, 0
push bx
push cx
push dx
mov cx, start_of_scroll
mov dx, end_of_scroll
mov bh, video_attribute
int videoIO
pop dx
pop cx
pop bx
pop ax
ret
printstring:
push ax
push bx
printloop:
mov bx, dx
mov al, [bx]
cmp al, eos
je string_ret
call conout
inc dx
jmp printloop
string_ret:
pop bx
pop ax
ret
cursor:
mov dx, 3D4H ;address register
mov al, 10 ;cursor start register
out dx, al ;select cursor start
mov dx,3D5H ;address data registers
mov al, cursor_start ;get "on" or "off" value
out dx, al ;cursor is now altered
ret
code ENDS
END